<template>
	<view class="share_content" v-loading="loading">
		<view class="content_" v-if="showBool==0">
			<view class="position_content">
				<Inventory2 :data="personData" />
			</view>
			<view class="position_content_main">
				<p class="fontz fontc3d fontw700 fonts12" style="margin-bottom: 10px;">职位描述</p>
				<p class="fontz fonts12 color2" style="white-space:pre-wrap;" v-html="personData.positionDesc"></p>
			</view>
			<view class="" style="margin-top: 8px;" @click="compony()">
				<ComponyRouter :data="personData.tenantVo" />
			</view>
			<!-- <view class="position_footer flex aic jcsb">
				<el-button class="blue_btn" style="width: 100%;" type="primary" @click="unlogin()">
					投递简历
				</el-button>
			</view> -->
		</view>
		<view class="" v-if="showBool==1">
			<view class="" style="margin-top: 8px;" @click="compony()">
				<ComponyRouter :data="personData.tenantVo" />
			</view>
			<view class="content_" style="padding: 0px 12px 10px 12px;">
				<view class="" @click="detail(item)" v-for="item in positionData">
					<Inventory :data="item" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getselects,
		getposition,
		registration,
		collection,
		editRegistration,
		registrationLog,
	} from "@/api/index"
	import UploadFileT from "@/pages/components/UploadFileT.vue"
	import UploadFileF from "@/pages/components/UploadFileF.vue"
	import Inventory2 from "@/pages/components/Invebtory_detail.vue";
	import ComponyRouter from "@/pages/components/ComponyRouter.vue";
	import Inventory from "@/pages/components/Inventory.vue"
	import {
		dictFun,
		dictFunAll
	} from "@/util/dictionary"
	export default {
		components: {
			UploadFileF,
			Inventory2,
			ComponyRouter,
			UploadFileT,
			Inventory,
		},
		data() {
			return {
				logData: [],
				id: "",
				loading: false,
				personData: {
					positionRegistration: {
						medicalReportIds: ""
					}
				},
				indexValue: "-1",
				bId: "",
				showBool: 0,
				positionIds: [],
				positionData: [],
			};
		},
		onLoad(options) {
			console.log(options);
			this.showBool = options.showBool
			
			if (this.showBool == 0) {
				let params = options.positionId
				this.id = params
				this.loading = true
				this.getpositionApi(this.id)
				this.loading = true
				this.getselectApi_().then(res => {
					this.getpositionApi(this.id)
				})
			} else {
				let params = options.positionIds
				console.log(params);
				this.positionIds = params.split(",")
				console.log(this.positionIds);
				this.getselectApi_().then(res => {
					// this.getpositionApis(this.positionIds)
					this.positionIds.forEach((element, key) => {
						this.getpositionApis(element)
					})

				})
			}


		},
		methods: {
			urlFun() {
				const pages = getCurrentPages(); // 获取加载的页面
				const currentPage = pages[pages.length - 1]; // 获取当前页面的对象
				const url = currentPage.route; // 当前页面路径
				const options = currentPage.options; // 如果是通过路由带参数的页面，options将包含参数

				// 拼接参数
				let params = '';
				for (let key in options) {
					if (options.hasOwnProperty(key)) {
						params += `${key}=${options[key]}&`;
					}
				}
				if (params.length > 0) {
					params = params.substring(0, params.length - 1); // 移除最后一个"&"
				}
				let currentUrl = `${url}?${params}`
				console.log("参数:",this.personData);
				uni.setStorageSync('currentUrl', this.personData);
			},
			detail(item) {
				uni.navigateTo({
					url: "/pages/index/position/sharePosition/sharePosition?showBool=0&positionId=" + item.id
				})
			},
			compony() { //去往公司
				uni.navigateTo({
					url: "/pages/index/compony/compony?data=" + JSON.stringify(this.personData)
				})
			},
			async getpositionApi(params) {
				await getposition(params).then((res) => {
					this.loading = false
					console.log("个人信息：", res);
					this.personData = res.data
					this.bId = this.personData.registrationFormTemplateId
				})
			},
			async getpositionApis(params) {
				await getposition(params).then((res) => {
					this.loading = false
					console.log("个人信息：", res);
					this.positionData.push(res.data)
					this.personData = res.data
					console.log(this.positionData);
					this.bId = res.data.registrationFormTemplateId
				})
			},
			async getselectApi_() {
				await getselects("requirements_years").then(res => {
					// console.log("工作年限:",res);
					uni.setStorageSync("requirements_years", res.data)
				})
				await getselects("education").then(res => {
					// console.log("学历:",res);
					uni.setStorageSync("education", res.data)
				})
				await getselects("company_type").then(res => {
					// console.log("公司性质:",res);
					uni.setStorageSync("company_type", res.data)
				})
				await getselects("company_size").then(res => {
					// console.log("公司规模:",res);
					uni.setStorageSync("company_size", res.data)
				})
				await getselects("company_industry").then(res => {
					// console.log("所属行业:",res);
					uni.setStorageSync("company_industry", res.data)
				})
				await getselects("position_nature").then(res => {
					// console.log("职位性质:",res);
					uni.setStorageSync("position_nature", res.data)
				})
				await getselects("welfare_treatment").then(res => {
					// console.log("福利:",res);
					uni.setStorageSync("welfare_treatment", res.data)
				})
				await getselects("sys_yes_no").then(res => {
					// console.log("是否:",res);
					uni.setStorageSync("sys_yes_no", res.data)
				})
				await getselects("sys_user_sex").then(res => {
					// console.log("性别:",res);
					uni.setStorageSync("sys_user_sex", res.data)
				})
				await getselects("key_population_information").then(res => {
					// console.log("重点人群:",res);
					uni.setStorageSync("key_population_information", res.data)
				})
				await getselects("marriage").then(res => {
					// console.log("婚姻:",res);
					uni.setStorageSync("marriage", res.data)
				})
				await getselects("position_nature").then(res => {
					// console.log("工作性质:",res);
					uni.setStorageSync("position_nature", res.data)
				})
				await getselects("salary").then(res => {
					// console.log("薪资:",res);
					uni.setStorageSync("salary", res.data)
				})
				await getselects("arrival_time").then(res => {
					// console.log("到岗时间:",res);
					uni.setStorageSync("arrival_time", res.data)
				})
				await getselects("status_of_job_hunting").then(res => {
					// console.log("求职状态:",res);
					uni.setStorageSync("status_of_job_hunting", res.data)
				})
				await getselects("proficiency_level").then(res => {
					// console.log("技能熟练度:",res);
					uni.setStorageSync("proficiency_level", res.data)
				})
				await getselects("political_outlook").then(res => {
					// console.log("政治面貌:",res);
					uni.setStorageSync("political_outlook", res.data)
				})
				await getselects("interview_type").then(res => {
					// console.log("面试方式:",res);
					uni.setStorageSync("interview_type", res.data)
				})
				await getselects("work_nature").then(res => {
					// console.log("面试方式:",res);
					uni.setStorageSync("work_nature", res.data)
				})
				await dictFunAll()
				await this.statusBack()
			},
			statusBack() {
				return true
			},
			unlogin() {
				this.urlFun()
				uni.removeStorageSync('userInfoData_') //移除登录信息
				setTimeout(() => {
					uni.navigateTo({
						url: "/pages/login/login"
					})
				}, 1000)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.position_content_main {
		margin-top: 10px;
		padding: 12px 12px 14px 12px;
		width: calc(100% - 24px);
		// height: 74px;
		background: #FFFFFF;
		border-radius: 0px 0px 0px 0px;
		opacity: 1;
	}

	.share_content {
		width: 375px;
		margin: auto;
		position: relative;
		// background-color: black;
	}

	.position_footer {
		height: 40px;
		z-index: 1;
		position: absolute;
		bottom: 0;
		background: #ffffff;
		box-shadow: 0px -1px 3px 0px rgba(48, 48, 48, 0.0592);
		border-radius: 0px 0px 0px 0px;
		opacity: 1;
		width: calc(100% - 24px);
		// padding: 12px;

		.blue_btn {
			background: #2F6CBC;
			border: 1px solid #2F6CBC;
		}
	}
</style>
